package dk.viauc.cmclang.intlang;

import java.io.IOException;
import java.util.Calendar;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JFileChooser;

import dk.viauc.cmclang.intlang.ast.AST;

public class TestDriveParser {

private static final String EXAMPLES_DIR = "C:\\Users\\Michal\\Documents\\7thSemester\\CMC\\workspace\\cmc";
	
	
	public static void main( String args[] ) throws SecurityException, IOException
	{
		JFileChooser fc = new JFileChooser( EXAMPLES_DIR );
		Handler hn =new FileHandler("parser.log");
		Logger.getLogger("").addHandler(hn);
		
		Logger.getLogger("").log(Level.FINE, "Start of the logging "+Calendar.getInstance().getTime());
		
		
		if( fc.showOpenDialog( null ) == fc.APPROVE_OPTION ) {
			SourceFile in = new SourceFile( fc.getSelectedFile().getAbsolutePath() );
			IScanner s = new Scanner( in );
			IParser p = new ParserAST( s );
		
			AST ast = (AST) p.parseProgram();
			new ASTViewer( ast );
		}
	}

}
